<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Pages_model extends MY_Model{

    function  __construct(){
        parent::__construct();
        $this->_table = TBL_PAGES;
    }

	function get_page($page_id = 0, $active = ACTIVE_FLAG){
        $this->db->select('*')->from(TBL_PAGES);
        $this->db->where('delete_flag', UNDELETE_FLAG);
        $this->db->where('draft', DRAFT_NO);
        if ($active != ''){
            $this->db->where('active_flag', $active);
        }

        if ($page_id != 0) {
            $this->db->where('id', $page_id);
            return $this->db->get()->row_array();
        } else {
            return $this->db->get()->result_array();
        }
    }

    function url_friendly($url = ''){
        $this->db->where('url_friendly', $url);
        $this->db->from(TBL_PAGES);
        return $this->db->get()->row();
    }
}
